package com.ddm.controller.vx;

import com.ddm.constant.MessageConstant;
import com.ddm.dto.vxDTO.QuestionDTO;
import com.ddm.dto.vxDTO.StandardExamDTO;
import com.ddm.exception.DataErrorException;
import com.ddm.result.PageResult;
import com.ddm.result.Result;
import com.ddm.service.StandardService;
import com.ddm.service.vxService.BonusPointService;
import com.ddm.service.vxService.QuetsionsService;
import com.ddm.vo.StandardDetailVO;
import com.ddm.vo.vxVo.BonusPointsVO;
import com.ddm.vo.vxVo.QuestionVO;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/user/standardExam")
@Slf4j
public class StandardExamController {
    @Autowired
    QuetsionsService quetsionsService;
    @Autowired
    BonusPointService bonusPointService;
    @Autowired
    StandardService standardService;

    @GetMapping
    @ApiOperation("获取标准真题列表")
    public Result<PageResult> getStandardList(){
        log.info("获取标准真题列表");
        return Result.success(standardService.pageQueryMenu());

    }

    @GetMapping("/{id}")
    @ApiOperation("根据标准id获取试题列表")
    public Result<List<QuestionVO>> getSEQList(@PathVariable Long id){
        log.info("根据标准真题获取试题列表");
        if (id == null){
            throw  new DataErrorException(MessageConstant.NULL_DATA);
        }
        return  Result.success(quetsionsService.getStandardQuestionList(id));
    }

    @PostMapping("/submit/{id}")
    @ApiOperation("提交标准真题")
    public Result<BonusPointsVO> submitStandardExam(@PathVariable Long id , @RequestBody List<StandardExamDTO> standardExamDTO){
        log.info("提交标准真题");
        if (id == null || standardExamDTO == null){
            throw  new DataErrorException(MessageConstant.NULL_DATA);
        }
        return Result.success(bonusPointService.submitStandardExam(id,standardExamDTO));
    }
}
